package com.anrongtec.zcpt.interfaces.theInferfaces;

import android.text.TextUtils;
import android.util.Log;

import com.lzy.okgo.callback.AbsCallback;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * http接口封装
 * cxy
 */

public class HttpInterfaces {


    public static Map<String,String> getCommonParams(){
        Map<String,String> params = new HashMap<>();
       // params.put("access_token", MyApplication.getInstance().getmAccessToken());
        return params;
    }

    /**
     * 检测更新
     */
    public static void checkVersion(Object tag, AbsCallback callback){
       // HttpUtil.get(MyApplication.getInstance().getConfig().CHECK_VERSION, null, callback, tag);
    }


    /**
     * 上传图片返回url
     */
    public static void uploadPic(List<String> filePaths, Object tag, AbsCallback callback){
       // HttpUtil.postFile(MyApplication.getInstance().getConfig().UPLOAD_URL, getCommonParams(), filePaths, callback, tag);
    }

    /**
     * 设置聊天背景图
     */
    public static void setChatBackground(String toUserId, String imageUrl, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("toUserId", toUserId);
        params.put("url", imageUrl);

        //HttpUtil.get(MyApplication.getInstance().getConfig().FRIENDS_BG, params, callback, tag);
    }

    /**
     * 修改用户信息
     * @param nickname
     * @param sex
     * @param description
     * @param birthday
     * @param cityId
     * @param tag
     * @param callback
     */
    public static void setUserInfo(String nickname, String sex, String description, String birthday, String cityId, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
            params.put("userType","0");
            params.put("nickname", nickname);
            params.put("sex", sex);
            params.put("description", description);
            params.put("birthday", birthday);
        if (!TextUtils.isEmpty(cityId))
            params.put("cityId", cityId);

       // HttpUtil.get(MyApplication.getInstance().getConfig().USER_UPDATE, params, callback, tag);
    }

    /**
     * 设置当前用户头像
     * @param avatar
     * @param tag
     * @param callback
     */
    public static void uploadAvatar(String avatar, Object tag, AbsCallback callback){
        Map<String, String> params = new HashMap<>();
//        params.put("userId", MyApplication.getInstance().getmLoginUser().getUserId());
//
//        HttpUtil.post(MyApplication.getInstance().getConfig().AVATAR_UPLOAD_URL, params, avatar, callback, tag);
    }

    /**
     * 设置朋友圈背景图
     */
    public static void setCircleBg(String bgImage, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("bgImage", bgImage);

        //HttpUtil.get(MyApplication.getInstance().getConfig().USER_UPDATE, params, callback, tag);
    }


    /**
     * 获取用户信息
     * @param userId
     * @param tag
     * @param callback
     */
    public static void getUser(String userId, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("userId", userId);
       // HttpUtil.get(MyApplication.getInstance().getConfig().USER_GET_URL, params, callback, tag);
    }



    /**
     * 设置群成员
     * @param roomId    房间Id
     * @param userId    成员Id：成员Id存在则更新，否则新增
     * token, roomId, userId, 为必须参数
     * @param role      角色Id：1=创建者、2=管理员、3=成员（不能为1）
     * @param talkTime  禁言结束时间：不禁言则为0、否则大于当前时间
     * @param sub       是否订阅群组消息：1=是、0=否
     * @param nickName  昵称
     */
    public static void updateGroupConstant(String roomId, String userId, int role, long talkTime, int sub, String nickName, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("roomId", roomId);
        params.put("userId", userId);
        params.put("role", role+"");
        params.put("talkTime", talkTime+"");
        params.put("sub", sub+"");
        params.put("nickname", nickName);
      //  HttpUtil.post(MyApplication.getInstance().getConfig().ROOM_MEMBER_UPDATE, params, callback, tag);
    }

    /**
     *  批量添加群成员
     * @param roomId        房间id
     * @param constants     成员id
     */
    public static void addGroupConstant(String roomId, List<String> constants, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("roomId", roomId);
       // params.put("text", GsonUtil.toJson(constants));
       // HttpUtil.post(MyApplication.getInstance().getConfig().ROOM_MEMBER_UPDATE, params, callback, tag);
    }

    /**
     * 加入群聊
     * @param roomId
     * @param tag
     * @param callback
     */
    public static void joinGroup(String roomId, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("roomId", roomId);
        params.put("type", "2");
      //  HttpUtil.post(MyApplication.getInstance().getConfig().ROOM_JOIN, params, callback, tag);
    }

    /**
     * 获取群信息
     * @param roomId
     * @param tag
     * @param callback
     */
    public static void getRoom(String roomId, Object tag, AbsCallback callback){
        Map<String, String> params = getCommonParams();
        params.put("roomId", roomId);
       // HttpUtil.post(MyApplication.getInstance().getConfig().ROOM_GET, params, callback, tag);
    }


    public static void getConfig(String url, AbsCallback callback){
        HttpUtil.get(url,null,callback,null);
    }

    public static void getSessionInfo(String url,String sessionkey, AbsCallback callback){

//        String urls = "http://192.168.20.241:11001/mpsession/session/get?" +
//                "sessionKey=APPSESSION:"+sessionkey+"&appKey=1&appSecret=2";


        String urls = url+sessionkey+"&appKey=1&appSecret=2";

        Log.d("url", urls);
        HttpUtil.get(urls,null,callback,null);
    }

    public static  void getXdjaBillInfo(String url,String bill,AbsCallback callback){

        HttpUtil.get(url+bill,null,callback,null);
    }

    public static void getPermissions(String url, AbsCallback callback){
        HttpUtil.get(url,null,callback,null);
    }

}
